﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using CoreShop.Model;
using CoreShop.Services;
using Sunny.UI;
using CoreShop.Library;
using System.Linq;
using SqlSugar.Extensions;
using System.Diagnostics.SymbolStore;
using System.Security.Cryptography;

namespace CoreShop.App
{
    public partial class frmFoodTemporary : UIForm
    {
        public frmFoodTemporary()
        {
            InitializeComponent();
            txtPrice.TextBox.GotFocus += txtPrice_GotFocus;
        }

        private void txtPrice_GotFocus(object sender, System.EventArgs e)
        {
            numPad.SetTextBox((UIEdit)sender, UITextBox.UIEditType.Double, 2);
        }

        private void frmTableOpen_Load(object sender, EventArgs e)
        {

        }

        private void numPad_OKButtonClick(object sender, string text, int intvalue, double doublevalue)
        {
            decimal price;
            string sInput = txtPrice.Text;
            if (string.IsNullOrEmpty(sInput)) sInput = "0";
            if (!decimal.TryParse(sInput, out price))
            {
                UIMessageBox.Show("请输入合法的单价。", "出错", UIStyle.Orange, UIMessageBoxButtons.OK);
                return;
            }
            if (price < 0)
            {
                UIMessageBox.Show("输入的单价不能为负数。", "出错", UIStyle.Orange, UIMessageBoxButtons.OK);
                return;
            }
            if (string.IsNullOrEmpty(txtName.Text))
            {
                UIMessageBox.Show("没有输入商品名称。", "出错", UIStyle.Orange, UIMessageBoxButtons.OK);
                txtName.Focus();
                return;
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void txtName_Enter(object sender, EventArgs e)
        {
            txtName.ShowDropDown();
        }

        private void frmFoodTemporary_Shown(object sender, EventArgs e)
        {
            txtPrice.Focus();
            txtName.Focus();
            txtName.ShowDropDown();
        }
    }
}
